Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
drag-enabled
Advanced tools
Have you looked at all the other Angular drag and drop libraries and noted they are not generic enough to fit within your design?
Have you looked at all the other Angular drag and drop libraries and noted they are not generic enough to fit within your design?
This library provides Angular 4 directives that enables you to have any html tag drag drop enabled within your component control just by adding DragDropModule into your AppModule.
You will be able to pass a medium object to the directives. The medium will supposedly have or know of certain things that can help your code make a decision on allowing a drag or a drop to take place. It could be a reference to a node or a structure in your code. At the start, a "dragEnabled" requst with a DragEvent will be sent to your component. if returned true, dragging begins. At the end of drag operation, an event with the source medium, source HTMLElement, destination medium, and destination HTMLElement will be sent to your component to perform any action necessary.
Had to remove renderer from the directives to avoid issues I was facing in stackblitz.io for creating live demo of complex components.
Added a DragInDocumentDirective to resolve issue found in Mozzila when there is a drag only process and a need to drag an element within a document. If you want to do a drag and drop on a node within hierarchy, we recommend you use DragDirective and DropDirective.
MODULE:
DragDropModule
EXPORTS:
DragDirective,
DragInDocumentDirective,
DropDirective
DEPENDENCIES:
basic Angular core libraries
Turned out that this library can become a lot more useful if I pass the event location as well. So here it is... Made the new attributes optional to make it compatible for those who are using previous version if they get an accidental upgrade through npm install...
export interface DragEvent {
medium: any,
node: HTMLElement,
clientX?: number,
clientY?: number,
offset?: {
x: number,
y: number
}
}
export interface DropEvent {
source: DragEvent,
destination: {
medium: any,
node: HTMLElement,
clientX?: number,
clientY?: number
}
}
MODULE:
DragDropModule
DEPENDENCIES:
basic Angular core libraries
Interfaces
export interface DragEvent {
medium: any,
node: HTMLElement
}
export interface DropEvent {
source: DragEvent,
destination: {
medium: any,
node: HTMLElement
}
}
The following are available functionalities presented in this version:
Sample code
<th scope="col"
[medium]="headerInfo"
[dragEnabled]="isDragEnabled.bind(this)"
[dropEnabled]="dropEnabled.bind(this)"
(onDragStart)="onDragStart($event)"
(onDrag)="onDrag($event)"
(onDragEnd)="onDragEnd($event)"
(onDrop)="onDrop($event)">header text</th>
.............
isDragEnabled(event: DragEvent) {
return event.medium.dragable;
}
onDragStart(event: DragEvent){
}
onDrag(event: DragEvent){
}
onDragEnd(event: DragEvent){
}
dropEnabled(event: DropEvent) {
return event.destination.medium.dragable;
}
onDrop(event: DropEvent){
// swapColumns(source.medium, source.node, destination.medium, destination.node);
}
.............
table {
th {
&.drag-over {
background-color: #9b9b9b;
.title, .icon {
color: #eee;
}
}
}
FAQs
Have you looked at all the other Angular drag and drop libraries and noted they are not generic enough to fit within your design?
We found that drag-enabled demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.